<template>
  <div class="box">
    <h3>父组件</h3>
    <h4>当前的n值是：{{n}}</h4>
    <button @click="add1">按钮1</button>
    <button @click="add2($event)">按钮2</button>
    <button @click="n += $event.target.innerText">按钮3</button>

    <!-- <Child @a="b"/> -->
    <Child @a="b($event)"/>
  </div>
</template>

<script>
  import Child from './Child.vue'

  export default {
    name: 'Index',
    components:{Child},
    data() {
      return {
        n:1
      }
    },
    methods: {
      add1(event){
        console.log(event)
        this.n += 1
      },
      add2(event){
        console.log(event)
        this.n += 1
      },
      b(value){
        console.log('b被调用了',value)
      }
    },
  }
</script>

<style lang="less" scoped>
	.box{
		background-color:rgb(178, 178, 178);
		padding: 20px;
    border-radius: 10px;
		button{
			margin-right: 5px;
		}
	}
</style>